new Vue({
  el: '#app',
  data: {
    active: 1,
    tabActive: 0,
    tabs: [{
      title: '今日排行',
      list: [],
      loading: false,
      finished: false,
      page: 1,
      type: 1,
    },{
      title: '历史排行',
      list: [],
      loading: false,
      finished: false,
      page: 1,
      type: 2,
    }]
  }, 
  mounted () {
    this.loading = false
    this.main()
  },
  methods: {
    main() {
      let tab = this.tabs[this.tabActive]
      this.getRankData(tab)
    },
    onTabChange() {
      let tab = this.tabs[this.tabActive]
      tab.list = []
      tab.page = 1;
      this.getRankData(tab)
    },
    getRankData(tab) {
      $http.get('/api/otc/rankinglist', { type: tab.type  }).then(res => {
        tab.list.push(...res.data.data)
      })
    }
  }
})